<template>
<div>
   
   <content_top title="账户设置"></content_top>
   
   <div class="g_box">
		<div class="g_head">
			<h3>账户设置</h3>
		</div>
		<div class="g_box_con" style="padding: 30px 50px;width:900px;;">
			<Form :model="info" label-position="right" :label-width="150">
				<Row>
					<Col span="12">
						<FormItem label="员工编号:">
							<Input :value="info.username" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="中文名:">
							<Input :value="info.nickname" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="Email:">
							<Input :value="info.email" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="英文名:">
							<Input :value="info.en_name" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="合同单位:">
							<Input :value="info.company" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="旧密码:">
							<Input v-model="info.old_password" type="password" style="width:240px;"></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="所属部门:">
							<Input :value="info.bumen" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="新密码:">
							<Input v-model="info.password" type="password" style="width:240px;"></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="所在地:">
							<Input :value="info.region" disabled style="width:240px;"></Input>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="确认密码:">
							<Input v-model="info.confirm_password" type="password" style="width:240px;"></Input>
							<p>为空默认不修改</p>
						</FormItem>
					</Col>
				</Row>
			</Form>
			
			<div style="text-align: center;margin: 30px;">
				<Button type="primary" @click="change_password">提交</Button>
			</div>
		</div>
	</div>
	
</div>
</template>

<script>
import Wcore from '@/libs/common';
import content_top from '@/themes/components/content_top';
export default {
    name: 'admin_info',
    data (){
		
        return {
            info:{
				
				old_password:'',
				password:'',
				confirm_password:''
			},
			id:0
        };
    },
	created(){
		this.load_data();
		
		this.$emit('change','admin');
	},
    components: {
       content_top
    },
	methods:{
		load_data(){
			var self = this;
			var postdata = {
				
			};
			Whttp.load('Admin/Admin/get_my_info',postdata,function(result){
				self.info = result;
				self.id = result.id;
			});
		},
		save(){
			var self = this;
			var postdata = {
				id:this.id,
				nickname:this.info.nickname
			};
			Whttp.load('Admin/Admin/save',postdata,function(result){
				self.$Message.info('保存成功');
				self.$router.back();
			});
		},
		change_password(){
			if(!confirm('是否修改密码')){
				return ;
			}
			var self = this;
			var postdata = {
				old_password:this.info.old_password,
				password:this.info.password,
				confirm_password:this.info.confirm_password
			};
			Whttp.load('Admin/Admin/change_password',postdata,function(result){
				self.$Message.info('修改成功');
			});
		}
	}
};
</script>